<template>
  <div>
    <el-container>
      <el-aside style="width: 200px; min-height: 100vh; background-color: #001529">
        <div style="height: 60px; color: aliceblue; display: flex; align-items: center; justify-content: center">
          <img src="@/assets/logo1.jpg" alt="" style="width: 40px; height: 40px">
          <span style="font-size: 20px; color: antiquewhite">&nbsp;&nbsp;Admin</span>
        </div>

<!--        当前浏览器访问的路由-->
        <el-menu router background-color="#001529" text-color="rgba(255,255,255,0.65)" active-text-color="#e7eaedbd" style="border: none" :default-active="$route.path">
          <el-menu-item index="/">
            <template slot="title">
              <i class="el-icon-house"></i>
              <span>首页</span>
            </template>
          </el-menu-item>
          <el-menu-item index="/">
            <template slot="title">
              <i class="el-icon-house"></i>
              <span>公告发布</span>
            </template>
          </el-menu-item>
          <el-menu-item index="/">
            <template slot="title">
              <i class="el-icon-house"></i>
              <span>申请审核</span>
            </template>
          </el-menu-item>
          <el-submenu>
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span>信息管理</span>
            </template>
            <el-menu-item>用户信息</el-menu-item>
            <el-menu-item>物资信息</el-menu-item>
            <el-menu-item>信息图表</el-menu-item>
          </el-submenu>
        </el-menu>

      </el-aside>
      <el-container>
          <el-header>
            <el-breadcrumb separator-class="el-icon-arrow-right" style="margin-left: 60px; margin-top: 20px; justify-content: center; font-size: 15px">
              <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
              <el-breadcrumb-item :to="{ path: '/user' }">用户管理</el-breadcrumb-item>
            </el-breadcrumb>
            <div cursor="default">
              <el-dropdown>
                <img src="@/assets/logo2.jpg" style="width: 40px; height: 40px; margin-top: -30px; margin-left: 5px">
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item>个人信息</el-dropdown-item>
                  <el-dropdown-item>修改密码</el-dropdown-item>
                  <el-dropdown-item @click="">退出登录</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>


            </div>
          </el-header>
        <!--        主体区域-->
        <el-main>
          <div style="box-shadow: 0 0 10px rgba(0,0,0,.1); padding: 10px 20px; border-radius: 5px; margin-bottom: 10px">
            早安，骚年，祝你开心每一天！
          </div>
          <div style="display: flex">
            <el-card style="width: 50%;margin-right: 10px">
              <div slot="header" class="clearfix">
                <span>青哥哥带你做毕设2024</span>
              </div>
              <div>
                2024毕设正式开始了！青哥哥带你手把手敲出来！
                <div style="margin-top: 20px">
                  <div style="margin: 10px 0"><strong>主题色</strong></div>
                  <el-button type="primary">按钮</el-button>
                  <el-button type="success">按钮</el-button>
                  <el-button type="warning">按钮</el-button>
                  <el-button type="danger">按钮</el-button>
                  <el-button type="info">按钮</el-button>
                </div>
              </div>

            </el-card>
            <el-card style="width: 50%">
              <div slot="header" class="clearfix">
                <span>渲染用户的数据</span>
              </div>
              <div>
                <el-table :data="users">
                  <el-table-column label="ID" prop="id"></el-table-column>
                  <el-table-column label="用户名" prop="username"></el-table-column>
                  <el-table-column label="姓名" prop="name"></el-table-column>
                  <el-table-column label="地址" prop="address"></el-table-column>

                </el-table>
              </div>
            </el-card>

          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>

import axios from "axios";
import request from "@/utils/request";

export default {
  name: 'HomeView',
  data() {
    return {
      isCollapse: false,  // 不收缩
      asideWidth: '200px',
      collapseIcon: 'el-icon-s-fold',
      users: []
    }
  },
  //请求数据，让它显示在网页上
  mounted() {
    // axios.get('http://localhost:8080/user/selectAll').then(res => {
    //   console.log(res.data) //后台返回的数据
    //   this.users = res.data.data
    //
    // })
    request.get('/user/selectAll').then(res => {
      this.users = res.data
    })
  },
  methods: {
    handleFull() {
      document.documentElement.requestFullscreen()
    },
    handleCollapse() {
      this.isCollapse = !this.isCollapse
      this.asideWidth = this.isCollapse ? '64px' : '200px'
      this.collapseIcon = this.isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'
    }
  }
}
</script>

<style>
.el-submenu .el-menu-item{
  background-color: #000c17 !important;
}
.el-menu-item:hover, .el-submenu__title:hover i{
  color: #fff !important;
}

.el-menu-item.is-active{
  border-radius: 7px;
  margin: 4px;
}
.el-menu-item{
  height:40px !important;
  line-height: 40px !important;
}
.el-submenu__title{
  height: 40px !important;
  line-height: 40px !important;
}
.el-header{
  box-shadow: 2px 0 6px rgba(0,21,41,35);
}

</style>
